<?php
$widget_params = isset($widget_params) ? $widget_params : [];
$choice_name = \Illuminate\Support\Arr::get($widget_params, 'name', 'product_id');
$choice_label = \Illuminate\Support\Arr::get($widget_params, 'label', '产品');
$choice_isPop = \Illuminate\Support\Arr::get($widget_params, 'isPop', 'false');
$choice_placeholder = \Illuminate\Support\Arr::get($widget_params, 'placeholder','请选择产品');
$search = isset($search) ? $search : \Illuminate\Support\Facades\Request::all();
?>
<div class="layui-form-item choice-container" id="choice-{{$choice_name}}">
    <label class="layui-form-label @if(isset($widget_params['required'])) layui-form-required @endif">{{$choice_label}}:</label>
    <div class="layui-input-block">
        <div class="choice-input">
            <input type="text" name="{{$choice_name.'_name'}}"
                   value="{{\Illuminate\Support\Arr::get($search,$choice_name.'_name','')}}" class="layui-input"
                   placeholder="{{$choice_placeholder}}"/>
        </div>
        <a class="layui-btn icon-btn">
            <input type="hidden" value="{{\Illuminate\Support\Arr::get($search,$choice_name,'')}}"
                   name="{{$choice_name}}"/>@lang('common.choice')
        </a>
    </div>
</div>
@push('script')
    <script type="text/javascript">
        SystemUtil.choice_render({
            url: "{{admin_url('archives/product/choose')}}",
            title: "@lang('common.choice_tpl',['name'=>$choice_label])",
            @if($choice_isPop=='true')
            window: parent,
            @endif
            elem: '#choice-{{$choice_name}}'
        });
    </script>
@endpush
